#include "Arduino.h"

typedef void (*encoder_callback)(boolean);
typedef void (*button_callback)();

class Encoder
{
	public:
		Encoder(byte pinA, byte pinB, byte pinC);
		void setPulse( encoder_callback cb );
		void setButton( button_callback cb );
		void begin();
		void poll();
		void setDelay ( int delay );

	private:
		byte _pinA;
		byte _pinB;
		byte _pinC;
		
		int _delay;

		byte _val;
		byte _pVal;
		byte _pulse;

		
		boolean a;
		boolean b;
		boolean c;
		boolean lastC;
		
		long lastMillis;

		encoder_callback callback;
		button_callback btnCallback;
};